using System;
using System.Collections;


using System;

// 抽象表达式接口
public interface AbstractExpression
{
    Object Interpret(String info);
}

// 终结者表达式类
public class TerminalExpression : AbstractExpression
{
    public Object Interpret(String info)
    {
        Console.WriteLine("TerminalExpression interprets info: " + info);
        return info; // 假设返回解析结果
    }
}

// 非终结者表达式类
public class NonTerminalExpression : AbstractExpression
{
    private AbstractExpression exp1;
    private AbstractExpression exp2;

    public NonTerminalExpression(AbstractExpression exp1, AbstractExpression exp2)
    {
        this.exp1 = exp1;
        this.exp2 = exp2;
    }

    public Object Interpret(String info)
    {
        Console.WriteLine("NonTerminalExpression interprets info: " + info);
        Object result1 = exp1.Interpret(info);
        Object result2 = exp2.Interpret(info);
        // 假设返回两个表达式结果的组合
        return result1.ToString() + ", " + result2.ToString();
    }
}

// 环境类
public class Context
{
    private AbstractExpression exp;

    public Context(AbstractExpression exp)
    {
        this.exp = exp;
    }

    public Object Parse(String info)
    {
        return exp.Interpret(info);
    }

    public Object GetValue()
    {
        return Parse("some info");
    }
}

// 访问类
public class Client
{
    public static void Main()
    {
        AbstractExpression terminal = new TerminalExpression();
        AbstractExpression nonTerminal = new NonTerminalExpression(terminal, terminal);

        Context context = new Context(nonTerminal);
        Object result = context.GetValue();
        Console.WriteLine("Result: " + result);
    }
}

//输出结果：
//NonTerminalExpression interprets info: some info
//TerminalExpression interprets info: some info
//TerminalExpression interprets info: some info
//Result: some info, some info